package com.gadgets.bm09.controller;

import com.gadgets.bm09.common.dto.DataTaskOperationDTO;
import com.gadgets.bm09.common.dto.EmcyDataImportDTO;
import com.gadgets.bm09.fegin.IEmcyController;
import com.gadgets.framework.annotation.RoleAuthCheck;
import com.gadgets.framework.common.dto.HttpBaseResp;
import com.gadgets.framework.common.exception.GadgetsServiceException;
import com.gadgets.framework.common.util.FeginRequestMapUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;

/**
 * 功能说明：
 *
 * @author Unclexiu
 * @version V202101.00.000
 * @data 2022-08-02
 * 修改记录：  修改日期          修改人员    修改说明
 * 2022-08-02  xiujunqing   创建文件
 */
@SuppressWarnings("rawtypes")
@RestController
@RequestMapping(value = "/bm09")
public class GadgetsBm09Fork {

	@Autowired
	private IEmcyController emcyController;

	@RoleAuthCheck
	@RequestMapping(value = "/dataImport.do")
	public HttpBaseResp importEmcyData(EmcyDataImportDTO importDTO) throws GadgetsServiceException{
		HashMap<String ,Object> requestParam = new HashMap<>();
		FeginRequestMapUtil.parseRequestParam(importDTO, requestParam);
		return emcyController.importEmcyData(requestParam);
	}

	/**
	 * 新增数据分析任务
	 * @param request						网络请求信息
	 * @param response						网络应答信息
	 * @param dto							新增信息
	 * @return								新增信息
	 * @throws GadgetsServiceException		服务异常
	 */
	@RoleAuthCheck
	@RequestMapping(value = "/analysis/addTask.do")
	public HttpBaseResp addDatAnalysisTask(HttpServletRequest request, HttpServletResponse response, DataTaskOperationDTO dto) throws GadgetsServiceException{
		HashMap<String ,Object> requestParam = new HashMap<>();
		FeginRequestMapUtil.parseRequestParam(dto, requestParam);
		return emcyController.addDatAnalysisTask(requestParam);
	}

}
